export default{
	data(){
		return {
			modal1:false,
			ids:[],//多选
			list:[],//列表
			selection:[],
			filter:{
				page:1,
				limit:2,
				name:"",
				total:0,
				cateId:null
			}
		}
	},
//	this.$route.path.split('/')[2]
	methods:{
		handleSelectAll (status) {			
            this.$refs.selection.selectAll(status);
        },
        removeSelect(selection){        	
       		this.selection=selection;
        },
        //多选删除
        removeSelectAll(){
//      	var _this = this;
        	this.selection.forEach((element)=>{
//      		console.log(element._id)       	
        		this.$http({
	        		method:'delete',
	        		url:`http://localhost:3000/${this.module}/data/`+element._id,	        		
	        	}).then((response)=>{
	        		console.log(response)
	        		this.getData();
	        	})	        	
        	})       	
        },
		onPageSizeChange(pageSize){
			this.filter.limit=pageSize;
			this.getData();
		},
		changePage(page){
			this.filter.page=page;
			this.getData();
		},
		getData(){
//			console.log(this.module)
			this.$http({
				method:"POST",
				url:`http://localhost:3000/${this.module}/list`,
				data:this.filter
			})
			.then(res=>{
//				console.log(res)
				this.list=res.data.rows;
				this.filter.total=res.data.total;
			})
		},
		remove (id,index) {
        	this.$http({
        		method:'delete',
        		url:`http://localhost:3000/${this.module}/data/`+id,	        		
        	}).then((response)=>{
        		this.list.splice(index, 1);
        	})             
        },
		editData (id) {
            	this.$http({
   					method:"GET",
   					url:`http://localhost:3000/${this.module}/data/`+id,
   				}).then((response)=>{
					this.formValidate=response.data;
	        	})
                this.modal1=true;
            },
        search(){
        	this.getData();
        }
	},
	created(){
		this.getData()
	}
}
